home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
-
- # QUERY_STRING stores the name of the absolute path to the compressed
- # tar file to transmit and then remove
- $abstmpdirpathNfile = $ENV{'QUERY_STRING'} ;
- $abstmpdirpathNfile =~ /(.*)\/[^\/]*$/;
- $abstmpdirpath = $1;
-
- if (! -f $abstmpdirpathNfile) {
- $str1 = "Content-type: text/html\n\n";
- syswrite(STDOUT,$str1,length($str1));
- $str2 = "File not found: $abstmpdirpathNfile<P>\n";
- syswrite(STDOUT,$str2,length($str2));
- exit 0;
- }
-
- $str1 = "Content-type: application/octet-stream \n\n";
- syswrite(STDOUT,$str1,length($str1));
- open (INFILE, "<$abstmpdirpathNfile");
- while ($len = sysread(INFILE, $buf, 16384)) {
- if (!defined $len) {
- next if $! =~ /^Interrupted/;
- die "System read error: $!\n";
- }
- $offset = 0;
- while ($len) { # handle partial writes
- # in case syswrite doesn't write all of the buffer
- $written = syswrite(STDOUT, $buf, $len, $offset);
- die "System write error: $!\n" unless defined $written;
- $len -= $written;
- $offset += $written;
- }
- }
- close (INFILE);
- unlink ($abstmpdirpathNfile);
- if (! rmdir ($abstmpdirpath)) {
- $val = "rmdir failed:$!";
- open (INFILE, "> /usr/tmp/DTsee$$");
- syswrite(INFILE,$val,length($val));
- $val = "\n\n and, abstmpdirpath == $abstmpdirpath\n" ;
- syswrite(INFILE,$val,length($val));
- close (INFILE);
- };
-